package com.godyao.controller;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author godyao
 * @date 2022/3/18
 */
@RestController
@RequestMapping("/mq")
public class RabbitMqController {
    @Autowired
    private AmqpTemplate rabbitTemplate;

    @GetMapping("/send/{message}")
    public String sendMsg(@PathVariable String message) {
        rabbitTemplate.convertAndSend("myex", "direct.biz.ex", message);
        return "OK";
    }
}
